package com.greateffect.littlebud.lib.utils;

import android.media.MediaPlayer;

import java.io.IOException;

/**
 * Created by ZengCS on 2019/7/23.
 * E-mail:zengcs@vip.qq.com
 * Add:成都市天府软件园E3
 */
public class MediaPlayerUtils {
    public static int getAudioDuration(String url) {
        try {
            MediaPlayer mediaPlayer = new MediaPlayer();
            mediaPlayer.setDataSource(url);
            mediaPlayer.prepare();
            return mediaPlayer.getDuration();
        } catch (IOException e) {
            e.printStackTrace();
            return 0;
        }
    }
}
